use repeated_cross_section, clear

// muslim indicator
gen muslim=(paiperc=="06"|paiperc=="08")

// muslim mother
gen mothermuslim=(paimerc=="06"|paimerc=="08")
gen bothparents=(muslim==1&mothermuslim==1)
gen fatheronly=(muslim==1&mothermuslim==0)

// interactions
gen inter=muslim*treatedcoh
foreach x in bothparents fatheronly {
	gen inter`x'=`x'*treatedcoh
}

// linear trend
tab birthyear, gen(coh)
sum birthyear
local minyear=r(min)
local maxyear=r(max)-r(min)
gen t=birthyear-`minyear'+1
gen tmuslim=t*muslim

// father-mother birthplace FE
egen pbpl=group(paiperc)
egen mbpl=group(paimerc)

estimates clear
local sample if pnai28=="10" & female==1
local cl pbpl
estimates clear
reghdfe bacormore inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear)
eststo m1

reghdfe bacormore inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.surveyr)
eststo m2

reghdfe bacormore inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m3

reghdfe bacormore inter tmuslim `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m4

esttab m* using "TableB4.csv", star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace ///
		cells(b(fmt(a3) star) se(par)) stats(N r2)  ///
		keep(inter*) 
